package com.sc.nft.admin.controller;

/**
 * @author liGen
 * @version 1.0
 * @date 2023/11/22 1:32 下午
 */

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.admin.request.AdminPageRefundOrderRequest;
import com.sc.nft.admin.request.IdsRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.entity.dto.AdminPageRefundOrderDTO;
import com.sc.nft.service.MallOrderRefundService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * @author liGen
 * @version 1.0
 * @date 2023/11/9 3:48 下午
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/orderRefund")
@Api(tags = "售后模块")
public class MallOrderRefundController {

    private final MallOrderRefundService mallOrderRefundService;


    @ApiOperation(value = "售后列表", notes = "售后列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<Page<AdminPageRefundOrderDTO>> orderRefundPage(@RequestBody AdminPageRefundOrderRequest request) {
        Page<AdminPageRefundOrderDTO> adminPageRefundOrderDTOPage = mallOrderRefundService.getAdminPageRefundOrderDTO(request.getPageNo(), request.getPageSize(), request.getOrderNo(), request.getRefundNo(), request.getRefundStatus(), request.getRefundType(), request.getUserTel());
        return PageResult.success(adminPageRefundOrderDTOPage);
    }

    @ApiOperation(value = "售后详情", notes = "售后详情", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/details", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<AdminPageRefundOrderDTO> orderRefundDetails(@Valid @RequestBody IdRequest request) {
        AdminPageRefundOrderDTO adminRefundOrderDTO = mallOrderRefundService.getAdminRefundOrderDTO(request.getId());
        return Result.success(adminRefundOrderDTO);
    }
}
